package cn.com.mrAdv04;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;

import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import com.google.common.collect.Lists;

public class IntSumReducer extends
		Reducer<Text, DoubleWritable, Text, DoubleWritable> {

	@Override
	protected void reduce(Text key, Iterable<DoubleWritable> values,
			Context context) throws IOException, InterruptedException {

		// key 天然有序,sno是有序的,只需要考虑 : 相同sno下,对报销金额排序
		ArrayList<DoubleWritable> lists = Lists.newArrayList(values);
		Collections.sort(lists);
		for (DoubleWritable list : lists) {
			context.write(key, list);
		}

	}
}
